#include <X11/Xlib.h>
#include <X11/extensions/XTest.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#define KeyRetrun "Return"
#define KeyBackSpace "BackSpace"


Display *dpy;
static void KylinVKForwardKey(int keycode) {
    printf( "func:%s, key:%d, dpy:%p\n",  __func__, keycode, dpy);
    XTestFakeKeyEvent(dpy, keycode, True, CurrentTime);
    XTestFakeKeyEvent(dpy, keycode, False, CurrentTime);
    XFlush(dpy);
}


int main(int argc, char *argv[]) {
    dpy = XOpenDisplay(getenv("DISPLAY"));
    //dpy = XOpenDisplay(nullptr);
    KylinVKForwardKey(38); //a
    KylinVKForwardKey(56); //b
    KylinVKForwardKey(54); //c
    sleep(1);
    KylinVKForwardKey(22); //BackSpace
    KylinVKForwardKey(36); //Enter
    XCloseDisplay(dpy);
    return 0;
}
